/*
 * Ganesa Copyright (C) 2008 Wim Crols <twimpiex@gnx.be>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License Version 3
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

package be.gnx.ganesa.application.controller;

import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;

import be.gnx.ganesa.application.command.Command;
import be.gnx.ganesa.application.command.NewProjectCommand;
import be.gnx.ganesa.application.model.Project;
import be.gnx.ganesa.application.ui.Ganesa;

public class NewProject implements SelectionListener {

  private Ganesa ganesa;

  public NewProject(Ganesa ganesa) {
    this.ganesa = ganesa;
  }

  public void widgetDefaultSelected(SelectionEvent selectionEvent) {
    NewProject.this.widgetSelected(selectionEvent);
  }

  public void widgetSelected(SelectionEvent selectionEvent) {
    Project project = ganesa.getApplication().getSelectedProject();
    if ((project != null) && (!project.isSaved())) {
      // a dialog should be shown
    }
    Command command = new NewProjectCommand(ganesa.getApplication());
    command.execute();
  }

}
